how to understand basic algorithms